<template>
  <div>
    <h2>papa的存款：{{ money }}</h2>
    <button @click="giveMoneyFromXM(100)">找小明借钱100</button>
    <button @click="giveMoneyFromXH(150)">找小红借钱150</button>
    <button @click="giveMoneyAll(200)">找所有小孩借钱200</button>
    <button @click="SendInfo">俺是papa</button>
    <br />
    <Son ref="xm"></Son>
    <Daughter ref="xh"></Daughter>
  </div>
</template>
  
  <script>
import Son from "./Son";
import Daughter from "./Daughter";

export default {
  name: "ChildrenParentTest",
  data() {
    return { money: 1000 };
  },
  methods: {
    giveMoneyFromXM(money) {
      this.money += money;
      this.$refs.xm.money -= money;
    },
    giveMoneyFromXH(money) {
      this.money += money;
      this.$refs.xh.money -= money;
    },
    giveMoneyAll(money) {
      this.money += 2 * money;
      this.$children.forEach((item) => (item.money -= money));
    },
    SendInfo(money) {
      this.$refs.xm.tractable();
    },
  },
  components: {
    Son,
    Daughter,
  },
};
</script>
  
  <style>
</style>